﻿@model  Li.DingTalk.Model.Contacts.userInfo
@{
    Layout = null;
}
<div class="easyui-layout" data-options="fit:true">
    <div data-options="region:'center'" style="padding:10px;">
        <form id="add_data" action="">
            <table width="100%">
                <tr>
                    <td align="right">名称：</td>
                    <td><input type="text" id="txtEditName" value="@Model.name" name="name" class="easyui-textbox" data-options="required:true" maxlength="20" /><span style="color:Red;margin-left:5px">*</span></td>
                </tr>
                <tr>
                    <td align="right">手机：</td>
                    <td>
                        <input type="text" name="mobile" value="@Model.mobile" class="easyui-textbox" data-options="required:true" maxlength="11" /><span style="color:Red;margin-left:5px">*</span>
                    </td>
                </tr>
            </table>
            <input type="hidden" value="@Model.userid" name="userid" />
            @Html.AntiForgeryToken()
        </form>
    </div>
    <div data-options="region:'south',border:false" style="text-align:right; height:33px; padding:3px 10px 0;">
        <a class="easyui-linkbutton" data-options="iconCls:'icon-ok'" id="btn_saveItem" href="javascript:void(0)" onclick="saveData()" style="width:80px">保存</a>
    </div>
</div>
<script type="text/javascript">
    function formIsValid() {
        //获取form id=add_data ，下html为input，css类为easyui-validatebox 的所有对象
        var validHtml = $("#add_data input.easyui-textbox");
        var flag = true;
        for (var i = 0; i < validHtml.length; i++) {
            //对每个对象进行验证，如果不通过则退出
            flag = $(validHtml[i]).textbox("isValid");
            if (!flag) {
                break;
            }
        }
        return flag;
    }

    function saveData() {
        var flag = formIsValid();
        if (!flag) return;
        //triminput("#add_data");
        var data = $("#add_data").serialize();
        $.ajax({
            type: "POST",
            url: "/Employee/Save",
            data: data,
            success: function (msg) {
                switch (msg) {
                    case "ok":
                        $.messager.alert('提示', '保存成功', 'info');
                        break;
                    case "false":
                        $.messager.alert('提示', '保存失败', 'error');
                        break;
                    default:
                        $.messager.alert('提示', msg, 'info');
                        break;
                }
            }
        });
    }
</script>


